home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / VLIB200.ZIP / VISUALIB.H < prev    next >
Text File  |  1993-11-04  |  29KB  |  774 lines

  1. /*****************************************************************************
  2.  
  3.                     Visualib Header File
  4.                     Copyright (c) 1993
  5.                     Visual Technology International, Co.
  6.                     P.O.Box 901-413
  7.                     Kansas City, MO 64190
  8.  
  9. *****************************************************************************/
  10.  
  11. /*****************************************************************************
  12.  
  13.                     Constants, types, and Macros
  14.  
  15. *****************************************************************************/
  16.  
  17. typedef double    real;
  18.  
  19. #define VOIDED  void far pascal
  20. #define DOUBLE  double far pascal
  21. #define FLOAT   float far pascal
  22. #define SHORT   short far pascal
  23. #define REAL    real far pascal
  24. #define BINARY  BOOL far pascal
  25.  
  26. typedef float huge    *hpfloat;
  27. typedef double far  *lpdouble;
  28. typedef float far   *lpfloat;
  29. typedef real far    *lpreal;
  30. typedef real        COORD;
  31. typedef COORD        COORD2[2];
  32. typedef COORD        COORD3[3];
  33. typedef COORD        COORD4[4];
  34. typedef COORD far    *LPCOORD;
  35. typedef COORD2 far    *LPCOORD2;
  36. typedef COORD3 far    *LPCOORD3;
  37. typedef COORD4 far    *LPCOORD4;
  38.  
  39. typedef real far    *VECTOR;
  40. typedef real far    *MATRIX;
  41.  
  42. typedef real    VECTOR2[2];
  43. typedef real    VECTOR3[3];
  44. typedef real    VECTOR4[4];
  45. typedef real    MATRIX2D[9];
  46. typedef real    MATRIX3D[16];
  47. typedef VECTOR2    far    *LPVECT2;
  48. typedef VECTOR3    far    *LPVECT3;
  49. typedef    VECTOR4 far    *LPVECT4;
  50. typedef VECTOR far *LPVECTOR;
  51.  
  52. typedef struct _tagPOINT2D {    /* 2D point coordinates */
  53.     real    x, y;
  54. } POINT2D, far *LPPOINT2D;
  55.  
  56. typedef struct _tagPOINT2H {    /* 2D homogeneous point coordinates */
  57.     real    x, y, w;
  58. } POINT2H, far *LPPOINT2H;
  59.  
  60. typedef struct _tagPOINT3D {    /* 3D point coordinates */
  61.     real    x, y, z;
  62. } POINT3D, far *LPPOINT3D;
  63.  
  64. typedef struct _tagPOINT3H {    /* 3D homogeneous point coordinates */
  65.     real    x, y, z, w;
  66. } POINT3H, far *LPPOINT3H;
  67.  
  68. typedef struct _tagBOX2D {
  69.     real    xmin, xmax, ymin, ymax;
  70. } BOX2D, far *LPBOX2D;
  71.  
  72. typedef struct _tagBOX3D {
  73.     real    xmin, xmax, ymin, ymax, zmin, zmax;
  74. } BOX3D, far *LPBOX3D;
  75.  
  76. typedef MATRIX3D far    *LPMTRX3D;
  77. typedef MATRIX2D far    *LPMTRX2D;
  78.  
  79. #define EPSILON (real) 1e-5
  80. #define QUTRPI  (real) 0.78539816
  81. #define HALFPI  (real) 1.57079633
  82. #define PI      (real) 3.14159265
  83. #define TWOPI   (real) 6.2831853
  84. #define DTOR    (real) 0.0174532
  85. #define ATOR    (real) 1.7453293e-3
  86. #define RTOD    (real) 57.295779
  87. #define    SQRT2    (real)1.414214
  88. #define    SQRT3    (real)1.732051
  89.  
  90. /* coordinate type */
  91. #define    VL_2D    0x1000
  92. #define    VL_3D    0x2000
  93. #define    VL_2H    0x0400
  94. #define    VL_3H    0x0800
  95.  
  96. /* viewer status flag */
  97. #define    VL_TWOD            8
  98. #define    VL_THREED        16
  99. #define    VL_CURRENT        128
  100.  
  101. /* light coordinate mode */
  102. #define    VL_WORLDLIGHT        0x0001
  103. #define    VL_CAMERALIGHT        0x0002
  104. #define    VL_OBJECTLIGHT        0x0004
  105.  
  106. /* light type */
  107. #define    VL_POINTLIGHT            0x0100
  108. #define    VL_DISTLIGHT            0x0200
  109. #define    VL_SPOTLIGHT            0x0400
  110. #define VL_AREALIGHT            0x0800
  111.  
  112. /* color type */
  113. #define    VL_MATERIALAMBIENT    0x0001
  114. #define    VL_MATERIALDIFFUSE    0x0002
  115. #define    VL_MATERIALSPECULAR    0x0003
  116. #define    VL_MATERIALEMISSION    0x0004
  117. #define    VL_AMBIENTREFLECT    0x0005
  118. #define    VL_DIFFUSEREFLECT    0x0006
  119. #define    VL_SPECULARREFLECT    0x0007
  120. #define    VL_EMISSIONSTRENGTH    0x0008
  121. #define    VL_SHININESS        0x0009
  122.  
  123. #define    VL_LIGHTCOLOR        0x0010
  124. #define    VL_AMBIENTCONTRIB    0x0020
  125. #define    VL_LIGHTLOCATION    0x0030
  126. #define    VL_LIGHTDIRECTION    0x0040
  127. #define    VL_LIGHTINTENSITY    0x0050
  128. #define    VL_SPOTLIGHTANGLE    0x0060
  129. #define    VL_SPOTLIGHTSPREAD    0x0070
  130.  
  131. #define    VL_ATTENUATION        0x0100
  132. #define    VL_GLOBALAMBIENT    0x0200
  133. #define    VL_BACKGROUNDCOLOR    0x0300
  134. #define    VL_SHADINGMETHOD    0x0400
  135. #define    VL_SHADINGMODEL        0x0500
  136. #define    VL_LOCALVIEWER        0x0600
  137. #define    VL_COUNTCLOCKWISE    0x0700
  138. #define    VL_TWOSIDESHADE        0x0800
  139. #define    VL_DEPTHBUFFER        0x0900
  140. #define    VL_BACKFACEREMOVAL    0x0A00
  141. #define    VL_PERTURBMATERIAL    0x0B00
  142. #define VL_PERTURBNORMAL    0x0C00
  143. #define    VL_PERTURBPIXEL        0x0D00
  144. #define VL_PERTURBFACET        0x0E00
  145. #define    VL_ENVIRONMENT        0x0F00
  146.  
  147. #define VL_INQUIRE            -1
  148.  
  149. /* projection mode */
  150. #define VL_PROJECTIONMODE  0x03
  151. #define VL_PERSPECTIVE     0x01
  152. #define VL_ORTHOGONAL      0x02
  153.  
  154. /* Viewport Mapping Mode */
  155. /*
  156. #define    VL_HORIZONTALFIT    1
  157. #define    VL_VERTICALFIT        2
  158. #define    VL_AUTOFIT            3
  159. #define    VL_VIEWPORTFIT        4
  160. */
  161. /* standard pen and brush color */
  162. #define    VL_NONE             0
  163. #define VL_RED           1
  164. #define VL_GREEN         2
  165. #define VL_BLUE          3
  166. #define VL_BROWN         4
  167. #define VL_MAGENTA       5
  168. #define VL_CYAN          6
  169. #define VL_WHITE         7
  170. #define VL_GRAY          8
  171. #define VL_LIGHTRED      9
  172. #define VL_LIGHTGREEN    10
  173. #define VL_LIGHTBLUE     11
  174. #define VL_YELLOW        12
  175. #define VL_LIGHTMAGENTA  13
  176. #define VL_LIGHTCYAN     14
  177. #define VL_LIGHTGRAY     15
  178. #define VL_BLACK         16
  179.  
  180. /* shading method */
  181. #define    VL_WIREFRAME            0x0001
  182. #define    VL_SOLIDFILL            0x0002
  183. #define    VL_CONTOURSHADE            0x0004
  184. #define    VL_GOURAUDSHADE            0x0008
  185. #define    VL_PHONGSHADE            0x0010
  186. #define    VL_FLATSHADE            0x0020
  187.  
  188. /* shading model */
  189. #define    VL_PHONGMODEL            0x0100
  190. #define    VL_SPECULARMODEL        0x0200
  191.  
  192. /* mark type */
  193. #define    VL_NULLMARK            0x0000
  194. #define    VL_CIRCLEMARK        0x0001
  195. #define    VL_CROSSMARK        0x0002
  196. #define    VL_XMARK            0x0004
  197. #define    VL_TRIANGLEMARK        0x0008
  198. #define    VL_BOXMARK            0x0010
  199. #define    VL_DIAMONDMARK        0x0020
  200. #define    VL_HEXAGONMARK        0x0040
  201. #define    VL_OCTAGONMARK        0x0080
  202.  
  203. /* arrow head type */
  204. #define    VL_NULLARROW        0x0000
  205. #define    VL_OPENARROW        0X0100
  206. #define    VL_CLOSEDARROW        0X0200
  207.  
  208. /* position mark type */
  209. #define    VL_CROSSHAIR    1
  210. #define    VL_ORIGIN        2
  211.  
  212. /* solid texture flag */
  213. #define    VL_MARBLE        0x0001
  214. #define    VL_WOODGRAIN    0x0002
  215. #define    VL_GRANITE        0x0004
  216.  
  217. /* Useful Macros */
  218. #define ABS(x)      (((x)>0)?(x):-(x))
  219. #define TRUNC(x)    ((int) (x))
  220. //#define ROUND(x)    (int)((x)+0.5f)
  221. #define    FLOOR(x)    (((x)>0) ? (int)(x) : -(int)(-(x)+1))
  222. #define    CEILING(x)    ((x)==(int)(x)?(x):(((x)>0)?1+(int)(x):-(1+(int)(-(x)))))
  223. #define    ROUND(x)    ((x)>0 ? (int)(x+0.5f) : -(int)(0.5f-x))
  224. #define SQR(x)          ((x)*(x))
  225. #define SQR2(x,y)       ((real)(SQR(x)+SQR(y)))
  226. #define SQR3(x,y,z)     ((real)(SQR(x)+SQR(y)+SQR(z)))
  227.  
  228. #define MAX(a,b)    (((a) > (b)) ? (a) : (b))
  229. #define MIN(a,b)    (((a) < (b)) ? (a) : (b))
  230. #define    SWAP(a,b)    { a^=b; b^=a; a^=b; }
  231. #define MIDVAL(a,b)     (((a)+(b))*0.5f)
  232. #define    LERP(a,l,h)    ((l)+(((h)-(l))*(a)))
  233. #define    CLAMP(v,l,h)    ((v)<(l) ? (l) : (v)>(h) ? (h) : (v))
  234. #define    STEP(v,s)    ((v)<(s) ? 0 : 1)
  235. #define    SIGN(x)        (((x)<0) ? -1 : (x)>0 ? 1 : 0)
  236.  
  237. #define    NEWLIST(type,n)    (type far *)_fmalloc (sizeof (type) * (n))
  238. #define    NEWITEM(type)    (type far *)_fmalloc (sizeof (type))
  239.  
  240. #define DIST2(x,y)      ((real)sqrt(SQR2(x,y)))
  241. #define DIST3(x,y,z)    ((real)sqrt(SQR3(x,y,z)))
  242. #define DETERM2(a,b,c,d)    ((a)*(d)-(b)*(c))
  243. #define DETERM3(a,b,c,d,e,f,g,h,i) ((a)*DETERM2(e,f,h,i)+(b)*DETERM2(f,d,i,g)+(c)*DETERM2(d,e,g,h))
  244.  
  245. #define VSET2(v,x,y)        ((v)[0]=(real)(x),(v)[1]=(real)(y))
  246. #define VSET3(v,x,y,z)        ((v)[0]=(real)(x),(v)[1]=(real)(y),(v)[2]=(real)(z))
  247. #define VSET4(v,x,y,z,w)    ((v)[0]=(real)(x),(v)[1]=(real)(y),(v)[2]=(real)(z),(v)[3]=(real)(w))
  248. #define    VGET2(v,x,y)        (x=(v)[0],y=(v)[1])
  249. #define    VGET3(v,x,y,z)        (x=(v)[0],y=(v)[1],z=(v)[2])
  250. #define    VGET4(v,x,y,z,w)    (x=(v)[0],y=(v)[1],z=(v)[2],w=(v)[3])
  251.  
  252. /*****************************************************************************
  253.  
  254.                     Function Prototypes
  255.  
  256. *****************************************************************************/
  257.  
  258. /*****************************************************************************
  259.  
  260.                     Basic Functions
  261.  
  262. *****************************************************************************/
  263.  
  264. BINARY    InitializeVisualib (void);
  265. VOIDED  ExitVisualib (void);
  266. VOIDED    AboutVisualib (void);
  267. VOIDED    LicenseInfo (void);
  268.  
  269. /* utility functions */
  270. BINARY  MessageOn (int flag);
  271. VOIDED  ErrorMessage (LPSTR msg);
  272. VOIDED    Message (LPSTR msg);
  273. COLORREF WINAPI    SelectColor (COLORREF color);
  274.  
  275. SHORT   NumViewer (void);
  276. VOIDED  SetPoint2D (LPPOINT2D point, real x, real y);
  277. VOIDED  SetPoint3D (LPPOINT3D point, real x, real y, real z);
  278. VOIDED  Se